package com.etc.youkeshoppingssm.controller;

import com.etc.youkeshoppingssm.entity.Category;
import com.etc.youkeshoppingssm.entity.Goods;
import com.etc.youkeshoppingssm.service.IGoodsService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
@RequestMapping("/goods")
public class GoodsController {
    private final static Logger logger = LoggerFactory.getLogger(GoodsController.class);
    @Autowired
    private IGoodsService service;
    @RequestMapping("/showIndex")
    @ResponseBody
    public List<Category> showIndex(){
        return service.showIndex();
    }
    @RequestMapping("/id/{id}")
    @ResponseBody
    public Goods findOfGoods(@PathVariable("id") int id){
        Goods goods = service.findOfGood(id);
        logger.info("{}",goods);
        return goods;
    }
}
